//
//  WD_ZiLiaoTwoTableView.m
//  BUDING
//
//  Created by 景强 on 16/4/11.
//  Copyright © 2016年 HanWoonYong. All rights reserved.
//

#import "WD_ZiLiaoTwoTableView.h"
#import "WD_ZiLiaoCollection.h"
#import "DrawView.h"



@interface WD_ZiLiaoTwoTableView()<UICollectionViewDelegate, UICollectionViewDataSource>

@property (nonatomic, strong) UICollectionView *collectionView;


@end


@implementation WD_ZiLiaoTwoTableView

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        DrawView *drawView = [[DrawView alloc] initWithFrame:self.contentView.frame];
        drawView.backgroundColor = [UIColor yellowColor];
        [self.contentView addSubview:drawView];
        [drawView setNeedsDisplay];
        
        
        UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
        flowLayout.itemSize = CGSizeMake(100, 130);
        flowLayout.sectionInset = UIEdgeInsetsMake(10, 10, 10, 10);
        flowLayout.minimumInteritemSpacing = 20;
        flowLayout.minimumLineSpacing = 20;
        self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:flowLayout];
        self.collectionView.dataSource = self;
        self.collectionView.delegate = self;
        self.collectionView.backgroundColor = [UIColor whiteColor];
        [self.collectionView registerClass:[WD_ZiLiaoCollection class] forCellWithReuseIdentifier:@"cell"];
        [self.contentView addSubview:self.collectionView];
        
        
    }
    
    
    return self;
    
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    
    self.collectionView.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height);
    
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    
    WD_ZiLiaoCollection *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    NSArray *arrayName = @[@"视频", @"语音", @"吐槽", @"专辑", @"图片", @"帖子"];
    cell.labelOne.text = arrayName[indexPath.row];
    NSArray *arrayImage = @[@"视频", @"语音", @"吐槽", @"专辑", @"图片", @"帖子"];
    cell.imagePicOne.image = [UIImage imageNamed:arrayImage[indexPath.row]];
    //    cell.backgroundColor = [UIColor yellowColor];
    return cell;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    
    return 6;
    
}



















/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end
